<template>
  <div class="Yueqing">
    <h1>你好,这里是温州理工滨海校区</h1>
    <!-- 添加学生查找功能 -->
    <div class="student-search">
      <input v-model="studentId" placeholder="请输入学号" />
      <button @click="searchStudent">查找学生</button>
    </div>
    <!-- 显示查找结果 -->
    <div v-if="foundStudent" class="student-info">
      <h2>学生信息</h2>
      <p>学号: {{ foundStudent.id }}</p>
      <p>姓名: {{ foundStudent.name }}</p>
      <p>年龄: {{ foundStudent.age }}</p>
      <p>专业: {{ foundStudent.major }}</p>
    </div>
    <div v-else-if="searched && !foundStudent" class="no-result">
      <p>未找到该学生信息</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      studentId: '', // 用户输入的学号
      foundStudent: null, // 查找结果
      searched: false, // 是否已搜索
      // 模拟学生信息数据
      students: [
        { id: '1', name: '张三', major: '计算机科学',age: 20 },
        { id: '2', name: '李四', major: '软件工程',age: 21 },
        { id: '3', name: '王五', major: '网络工程',age: 22 }
      ]
    };
  },
  methods: {
    searchStudent() {
      this.searched = true;
      this.foundStudent = this.students.find(student => student.id === this.studentId);
    }
  }
};
</script>

<style scoped>
.student-search {
  margin-top: 20px;
}
.student-info, .no-result {
  margin-top: 20px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}
</style>